package testBitmap
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import testBitmap.Block;
	
	public class BlockManager extends Sprite 
	{
		private var _block:Block;
		
		public function BlockManager() 
		{
		}
		
		public function createBlockManagerSource(width:Number, height:Number, colum:Number, row:Number):void
		{
			for (var __c:int = 0; __c < colum; __c++)
            {
                for (var __r:int = 0; __r < row; __r++)
                {
					_block = new Block();
					_block.createBackgrnd(width * __c / colum, height * __r / row, width / colum, height / row);
					addChild(_block);
					
					_block.addEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown, false, 0, true);
					_block.addEventListener(MouseEvent.MOUSE_UP, _onMouseUp, false, 0, true);
				}
			}	
		}
		
		private function _onMouseDown(e:MouseEvent):void
        {
            var __s:Sprite = Sprite(e.currentTarget);
           
            __s.addEventListener(MouseEvent.MOUSE_UP, _onMouseUp, false, 0, true);
            __s.startDrag();
        }
		
		private function _onMouseUp(e:MouseEvent):void
        {
            var __s:Sprite = Sprite(e.currentTarget);
            __s.stopDrag();
        }
	}

}